<template>
  <div>

  </div>
</template>

<script>
// 菜单组件
import bus from "emitvue";
let Menu = require("electron").remote.Menu;
export default {
  name: "MyMenu",
  data() {
    return {
      // 自动分析
      autoAnalyze :false,

    }
  },
  methods: {
    createdMenu() {
      let template = [
        {
          label: "菜单",
          submenu: [
            {
              label: "新的一局",
              accelerator: 'shift+N',
              click: () => {
                bus.$emit("newGame");
              },
            },

          ],
        },
        {
          label: "工具",
          submenu: [
            {
              label: "自动分析",
              type: "checkbox",
              click: () => {
                //点击后取反
                this.autoAnalyze = !this.autoAnalyze;
                this.switchAnalyze();
              },
              checked: this.autoAnalyze,
              accelerator: 'shift+1',
            },
            {
              label: "获取fen",
              click: () => {
                this.getFen2Clipboard();
              },
              accelerator: 'shift+A',
            },
            {
              label: "翻转棋盘",
              click: () => {
                this.reverseBoard();
              },
              accelerator: 'ctrl+F',
            },
            {
              label: "自由移动",
              click: () => {
                this.freeMove();
              },
              accelerator: 'shift+F',
            }
          ]
        }
      ];
      let MyMenu = Menu.buildFromTemplate(template);
      Menu.setApplicationMenu(MyMenu);
    },
    switchAnalyze() {
      bus.$emit("switchAnalyze",this.autoAnalyze);
    },
    getFen2Clipboard(){
      bus.$emit('getFen2Clipboard',null);
    },
    reverseBoard(){
      bus.$emit('reverseBoard',null);
    },
    freeMove() {
      bus.$emit('freeMove',null);
    }
  },
  mounted() {
    this.createdMenu();

  },
}
</script>

<style scoped>

</style>
